//=============================================================================
//                             TOUCH Status
//                         	bit0 - TouchDown(1) / Up(0)
//							bit1 - ButtonDown(1) / Up(0)  : TouchDown over 10msec
//							bit2 - Cliked(1) : Button Down & Up is same place		
//							bit3 - Drag(1)
//=============================================================================
#define	TOUCHPRESS			1
#define	TOUCHMOVED			2
#define	TOUCHEND			3
#define	TOUCHCLICK			4
#define	TOUCHDOUBLECLICK	5
#define	TOUCHLONGCLICK		6
#define	TOUCHMOVE			10
#define	TOUCHMOVEUP			11
#define	TOUCHMOVEDOWN		12
#define TOUCHMOVELEFT		13
#define TOUCHMOVERIGHT		14

#define	TOUCH_DOWN			0x01
#define	TOUCH_BUTTON		0x02
#define	TOUCH_CLICK			0x04
#define	TOUCH_DRAG			0x08


//TEMP
#define KEY_RIGHT			1
#define KEY_UP				2
#define KEY_MENU			3
#define KEY_DOWN			4
#define KEY_LEFT			5
#define	KEY_INPUT			6


extern BYTE	TouchStatus;
extern WORD		TouchX, TouchY;
extern bit		TouchPressed, TouchAuto, TraceAuto;

extern	DATA 	BYTE   	tm001;
extern	DATA 	WORD   	tm01;
extern	DATA 	BYTE   	tic01;
extern	DATA 	WORD   	tic_pc;
extern	DATA 	WORD   	tic_task;
extern	DATA 	DWORD	SystemClock;


void InitTouch( void );
void SaveCalibDataToEE(BYTE flag);
void ReadCalibDataFromEE(void);
void PrintCalibData(void);

//void UpdateTouchCalibXY(BYTE index,WORD x, WORD y);
WORD TouchGetCalibedX(BYTE index);					//friend 
WORD TouchGetCalibedY(BYTE index);					//friend 
void TouchSetCalibedXY(BYTE index, WORD x, WORD y);	//friend 

BYTE CheckTouchStatus( WORD *xpos, WORD *ypos);
void SetTouchStatus( BYTE ts );
void SetLastTouchStatus( BYTE ts );

void SetTouchAuto( BYTE on );
void CheckTouch( void );
void GetTouch( void );
BYTE GetTouch2(void);
void CalibTouch( BYTE n );

void SetTraceAuto( BYTE on );
void TraceTouch( void );
BYTE SenseTouch( WORD *xpos, WORD *ypos);
void TouchDump( void );
void WaitTouchButtonUp( void );

WORD GetVeloX( void );
WORD GetVeloY( void );

void InitTscAdc(BYTE mode);

void UartSendStr(BYTE *p,BYTE len);
void SendMenuposvalue(BYTE flag,WORD x,WORD y);